//
//  main.swift
//  Composite
//
//  Created by LY on 2017/10/24.
//  Copyright © 2017年 DesignPatterns. All rights reserved.
//

import Foundation
let doorWindows = CompositePart(name: "DoorWindows", part: Part(name: "Window", price: 100.50),Part(name: "Window Switch", price: 12))
let door = CompositePart(name: "Door", part: Part(name: "Window", price: 100.50),Part(name: "Door Loom", price: 80),Part(name: "Window Switch", price: 12),Part(name: "Door Handles", price: 43.30))

let hood = Part(name: "Hood", price: 320)
let order = CustomOrder(customer: "Bob", part: [hood], compositePart: doorWindows,door)
order.printDetails()

print("使用组合模式")
let doorWindows2 = CarCompositePart(name: "DoorWindows", parts: CarPart(name: "Window", price: 100.5),CarPart(name: "Window Switch", price: 12))
let door2 = CarCompositePart(name: "Door", parts: CarPart(name: "Window", price: 100.5 ),CarPart(name: "Window Switch", price: 12),CarPart(name: "Door Loom", price: 80),CarPart(name: "Door Handlers", price: 43.3))
let hood2 = CarPart(name: "Hood", price: 320)
let order2 = CustomCarOrder(name: "Bob", Parts: door2,doorWindows2,hood2)
order2.prinAll()


AAAA(nane: "a", description: "A", category: "a")

